fix Storage of sensitive information in build artifact #6635
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
kitsune/webpack.common.js
Lines 110 to 112 in d7ba74f
fix the issue should avoid including all environment variables in the build artifact. Instead, we should explicitly whitelist only the environment variables that are safe and necessary for the application to function. This can be achieved by creating a new object that contains only the required variables and passing it to
webpack.DefinePlugin
.In this case, we will replace the current
webpack.DefinePlugin
configuration to include only a specific set of environment variables, such asDEBUG
or any other explicitly defined variables.Sensitive information included in a build artifact can allow an attacker to access the sensitive information if the artifact is published. The following creates a
webpack
configuration that inserts all environment variables from the host into the build artifact:The environment variables might include API keys or other sensitive information, and the build-system should instead insert only the environment variables that are supposed to be public. for fixed below, where only the
DEBUG
environment variable is inserted into the artifact.References
DefinePlugin API
CWE-312
CWE-315
CWE-359